/*    */ package service;
/*    */ 
/*    */ import java.io.IOException;
/*    */ import java.util.concurrent.CopyOnWriteArraySet;
/*    */ import javax.websocket.OnClose;
/*    */ import javax.websocket.OnMessage;
/*    */ import javax.websocket.OnOpen;
/*    */ import javax.websocket.Session;
/*    */ import javax.websocket.server.ServerEndpoint;
/*    */ 
/*    */ 
/*    */ @ServerEndpoint("/webSocket")
/*    */ public class WebSocket
/*    */ {
/*    */   private Session session;
/* 16 */   private static CopyOnWriteArraySet<WebSocket> webSockets = new CopyOnWriteArraySet();
/*    */   
/*    */   @OnOpen
/*    */   public void onOpen(Session session) {
/* 20 */     this.session = session;
/* 21 */     webSockets.add(this);
/*    */   }
/*    */ 
/*    */   
/*    */   @OnClose
/* 26 */   public void onClose() { webSockets.remove(this); }
/*    */ 
/*    */   
/*    */   @OnMessage
/*    */   public void onMessage(String message) {}
/*    */ 
/*    */   
/*    */   public void sendMessage(String message) {
/* 34 */     for (WebSocket webSocket : webSockets) {
/*    */       try {
/* 36 */         webSocket.session.getBasicRemote().sendText(message);
/* 37 */       } catch (IOException e) {
/* 38 */         e.printStackTrace();
/*    */       } 
/*    */     } 
/*    */   }
/*    */ }


/* Location:              /Users/frank/Desktop/iotlab/WEB-INF/classes/!/service/WebSocket.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */